package com.dahua.messagesyncbj.config.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO {
    private int code;
    private String message;
    private Object data;
    public ResultVO(Object data) {
        this.data = data;
    }
    public static ResultVO success() {
        ResultVO result = new ResultVO();
        result.setCode(Code.SUCCESS_CODE.getCode());
        result.setMessage(Code.SUCCESS_CODE.getMessage());
        return result;
    }
    public static <Object> ResultVO success(Object data) {
        ResultVO result = new ResultVO(data);
        result.setCode(Code.SUCCESS_CODE.getCode());
        result.setMessage(Code.SUCCESS_CODE.getMessage());
        return result;
    }
    public static ResultVO success(int code, String message) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    public static <Object> ResultVO success(int code, String message, Object data) {
        ResultVO result = new ResultVO(data);
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    public static ResultVO failure(String message) {
        ResultVO result = new ResultVO();
        result.setCode(Code.FAIL_CODE.getCode());
        result.setMessage(message);
        return result;
    }
    public static ResultVO failure(int code, String message) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    public static <Object> ResultVO failure(int code, String message, Object data) {
        ResultVO result = new ResultVO(data);
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}
